package org.veloxbot.api.methods;

import org.veloxbot.api.utils.Random;

import java.awt.Point;
import java.awt.Rectangle;

/**
 * @author iJava
 */
public class Inventory {

	/**
	 * An enum of inventory slot bounds.
	 */
	public static enum Slot {
		SLOT_0(new Rectangle(563, 263, 36, 32)),
		SLOT_1(new Rectangle(605, 263, 36, 32)),
		SLOT_2(new Rectangle(647, 263, 36, 32)),
		SLOT_3(new Rectangle(689, 263, 36, 32)),
		SLOT_4(new Rectangle(563, 299, 36, 32)),
		SLOT_5(new Rectangle(605, 299, 36, 32)),
		SLOT_6(new Rectangle(647, 299, 36, 32)),
		SLOT_7(new Rectangle(689, 299, 36, 32)),
		SLOT_8(new Rectangle(563, 335, 36, 32)),
		SLOT_9(new Rectangle(605, 335, 36, 32)),
		SLOT_10(new Rectangle(647, 335, 36, 32)),
		SLOT_11(new Rectangle(689, 335, 36, 32)),
		SLOT_12(new Rectangle(563, 371, 36, 32)),
		SLOT_13(new Rectangle(605, 371, 36, 32)),
		SLOT_14(new Rectangle(647, 371, 36, 32)),
		SLOT_15(new Rectangle(689, 371, 36, 32)),
		SLOT_16(new Rectangle(563, 407, 36, 32)),
		SLOT_17(new Rectangle(602, 407, 36, 32)),
		SLOT_18(new Rectangle(647, 407, 36, 32)),
		SLOT_19(new Rectangle(689, 407, 36, 32)),
		SLOT_20(new Rectangle(563, 443, 36, 32)),
		SLOT_21(new Rectangle(605, 443, 36, 32)),
		SLOT_22(new Rectangle(647, 443, 36, 32)),
		SLOT_23(new Rectangle(689, 443, 36, 32)),
		SLOT_24(new Rectangle(563, 479, 36, 32)),
		SLOT_25(new Rectangle(605, 479, 36, 32)),
		SLOT_26(new Rectangle(647, 479, 36, 32)),
		SLOT_27(new Rectangle(689, 479, 36, 32));

		private final Rectangle bounds;

		private Slot(final Rectangle bounds) {
			this.bounds = bounds;
		}

		/**
		 * Gets the bounds of the slot.
		 *
		 * @return The bounds of the slot.
		 */
		public Rectangle getBounds() {
			return bounds;
		}

		private Point getCenterPoint() {
			return new Point((int) bounds.getCenterX(), (int) bounds.getCenterY());
		}

		/**
		 * Gets a random point in the slot's bounds.
		 *
		 * @return A random point in the slot's bounds.
		 */
		public Point getRandomPoint() {
			return new Point(((int) bounds.getCenterX() + Random.nextInt(-bounds.width / 2, bounds.width / 2)), ((int) bounds.getCenterY() + Random.nextInt(-bounds.height / 2, bounds.height / 2)));
		}
	}
}